home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / program / asm32.zip / E32.ZIP / SETUP.ASM < prev    next >
Assembly Source File  |  1996-03-30  |  6KB  |  384 lines

  1. ; SETUP.ASM for E32 - Copyright (C) 1994 - 1996 Douglas Herr
  2. ;  all rights reserved
  3.  
  4. ; 01/07/1996 DH: made printer_setup a public symbol
  5. ; 01/18/1996 DH: changed PICKSTR calls to PICKSTRING
  6.  
  7. include    model.inc
  8.  
  9. public    setup, printer_setup, pick_color
  10. extrn    pickstring:near, $tpick:near
  11. extrn    tprintce:near
  12. extrn    menuoption:near
  13. extrn    pickcolor:near
  14. extrn    ljsetup:near
  15. extrn    strupr:near
  16. extrn    strlwr:near
  17. extrn    ucursoron:near, getkey:near
  18. extrn    cursoroff:near
  19. extrn    print_msg:near
  20.  
  21. public    window_mode
  22. extrn    swap_files:near
  23. extrn    display_screen:near
  24.  
  25. include    dataseg.inc
  26. extrn    inverse:byte
  27. extrn    nul:byte
  28. extrn    display_mode:byte
  29. extrn    dirty_bits:byte
  30. extrn    saved_pos:dword
  31.  
  32. msg0    db 'Setup',0
  33. setup_menu    label    byte
  34. msg1        db 'Multi-file display',0
  35. msg1a        db 'File display mode',0
  36. msg2        db 'Screen colors',0
  37. msg3        db 'Printer',0
  38.         db 0
  39.  
  40. setup_dispatch    dd window_mode
  41.         dd ascii_or_hex
  42.         dd pick_color
  43.         dd printer_setup
  44.  
  45. setup_msg    dd msg1
  46.         dd msg1a
  47.         dd msg2
  48.         dd msg3
  49.  
  50. mode_menu    db 'ASCII display',0
  51.         db 'Hex display',0
  52.         db 0
  53.  
  54. printer_menu    label    byte
  55. p0        db 'Reset',0
  56. p1        db 'Landscape',0
  57. p2        db 'Lines per inch: '
  58. lpi_len        equ    $-p2
  59. lpi        db '6',0
  60. p3        db 'Compressed',0
  61.         db 0
  62.  
  63. printer_msg    dd p0
  64.         dd p1
  65.         dd p2
  66.         dd p3
  67.  
  68. reset_help    db 'Restore setup defaults',0
  69. land_help    db 'Landscape page orientation',0
  70. LPI_help    db 'Set page lines per inch',0
  71. compressed_help    db 'Compressed text',0
  72.  
  73. help_txt    dd reset_help
  74.         dd land_help
  75.         dd LPI_help
  76.         dd compressed_help
  77.  
  78. lpi_prompt    db '1,2,3,4,6 or 8:',0
  79. lpi_prompt_len    equ    $-lpi_prompt
  80.  
  81. ;
  82. ; SCREEN COLORS
  83. ;
  84.  
  85. extrn    default_normal:byte
  86. extrn    normal:byte, inverse:byte, warning:byte
  87. extrn    rows:byte, dirty_bits:byte
  88. extrn    window_row:byte
  89.  
  90. colors    label    byte
  91. nmsg    db 'Normal text',0
  92. pmsg    db 'Prompts and Marked blocks',0
  93. wmsg    db 'Warnings and Error messages',0
  94.     db 0
  95. bgrnd    db 'background',0
  96. fgrnd    db 'foreground',0
  97.  
  98. color_ptr    dd normal
  99.         dd inverse
  100.         dd warning
  101.  
  102. msg_ptr        dd nmsg
  103.         dd pmsg
  104.         dd wmsg
  105.  
  106. ;
  107. ; WINDOW MODE
  108. ;
  109. extrn    rows:byte, window_row:byte
  110.  
  111. choices    db 'Full screen',0
  112.     db 'Split screen',0
  113.     db 0
  114. two    db 'Two screens',0
  115.     db 0
  116. @curseg    ends
  117.  
  118.  
  119. include    codeseg.inc
  120. setup    proc    near
  121.     xor    ebx,ebx
  122.  
  123. next_setup:
  124.     lea    esi,msg0
  125.     call    print_msg
  126.     lea    esi,setup_menu
  127.     mov    dx,0808h
  128.     mov    eax,offset @curseg:$tpick
  129.     call    pickstring
  130.     jc    short setup_exit
  131.     cmp    ax,27
  132.     je    short setup_exit
  133.     push    ebx
  134.     shl    ebx,2
  135.     mov    esi,setup_msg[ebx]
  136.     call    print_msg
  137.     call    setup_dispatch[ebx]
  138.     pop    ebx
  139.     test    dirty_bits,1
  140.     jz    next_setup
  141.     mov    saved_pos,-1
  142.     call    display_screen
  143.     jmp    next_setup
  144.     
  145. setup_exit:
  146.     ret
  147. setup    endp
  148.  
  149.  
  150. ;
  151. ; SCREEN COLORS
  152. ;
  153.  
  154. color_selection    equ    ebp
  155.  
  156. pick_color    proc    near
  157.     push    ebp
  158. select:
  159.     mov    dx,0909h
  160.     xor    ebx,ebx
  161.     lea    esi,colors
  162.     mov    eax,offset @curseg:$tpick
  163.     call    pickstring
  164.     jc    color_exit
  165.     cmp    ax,27
  166.     je    color_exit
  167.     or    dirty_bits,00100000b
  168.     shl    ebx,2
  169.     mov    color_selection,ebx
  170.     mov    esi,msg_ptr[ebx]
  171.     call    print_msg
  172.  
  173. ; install trap
  174.     lea    eax,color_message
  175.     mov    ebx,7
  176.     call    menuoption
  177.  
  178.     mov    ebx,color_selection
  179.     mov    ebx,color_ptr[ebx]
  180.     mov    ah,[ebx]    ; get selected color
  181.     mov    dx,030Ah
  182.     call    pickcolor
  183.  
  184.     push    eax
  185.     xor    eax,eax
  186.     mov    ebx,7
  187.     call    menuoption
  188.     mov    esi,eax
  189.     mov    ah,inverse
  190.     mov    dh,window_row
  191.     dec    dh
  192.     xor    dl,dl
  193.     call    tprintce
  194.     pop    eax
  195.  
  196.     cmp    al,27
  197.     je    short color_exit
  198.     mov    ebx,color_selection
  199.     mov    ebx,color_ptr[ebx]
  200.     mov    [ebx],ah
  201.     lea    esi,normal
  202.     lea    edi,default_normal
  203.     mov    ecx,3
  204.     push    ds
  205.     pop    es
  206.     rep    movsb
  207.     or    dirty_bits,1
  208.     jmp    select
  209.  
  210.  
  211. color_message:
  212.     pushad
  213.     lea    esi,bgrnd
  214.     test    al,al
  215.     jz    short show_msg
  216.     lea    esi,fgrnd
  217. show_msg:
  218.     mov    dh,window_row
  219.     dec    dh
  220.     xor    dl,dl
  221.     call    tprintce
  222.     popad
  223.     ret
  224.  
  225. color_exit:
  226.     pop    ebp
  227.     ret
  228.  
  229. pick_color    endp
  230.  
  231.  
  232. ;
  233. ; DISPLAY MODE
  234. ;
  235. ascii_or_hex    proc    near
  236.     lea    esi,mode_menu
  237.     mov    dx,0909h
  238.     movzx    ebx,display_mode    ; default: current display mode
  239.     shr    ebx,2
  240.     mov    eax,offset @curseg:$tpick
  241.     call    pickstring
  242.     cmp    ax,27            ; ESC?
  243.     je    short ascii_or_hex_exit
  244.     shl    ebx,2
  245.     mov    display_mode,bl
  246.     or    dirty_bits,00100001b
  247.  
  248. ascii_or_hex_exit:
  249.     ret
  250. ascii_or_hex    endp
  251.  
  252.  
  253.  
  254. ;
  255. ; WINDOW MODE
  256. ;
  257.  
  258. window_mode    proc    near
  259.     lea    esi,choices
  260.     mov    dx,0909h
  261.     xor    ebx,ebx            ; first choice
  262.     mov    eax,offset @curseg:$tpick
  263.     call    pickstring
  264.     cmp    ax,27            ; ESC?
  265.     je    short window_mode_exit    ;  exit
  266.     cmp    ebx,1
  267.     sbb    eax,eax            ; 0 if split, -1 if full
  268.     not    eax
  269.     and    al,rows
  270.     shr    al,1
  271.     inc    al
  272.     xor    ebx,ebx
  273.     inc    ebx
  274.  
  275.     mov    window_row,al
  276.     push    ebx
  277.     call    swap_files
  278.     pop    ebx
  279.     call    swap_files
  280.     or    dirty_bits,00100001b
  281.     push    ds
  282.     pop    es
  283.  
  284. window_mode_exit:
  285.     ret
  286. window_mode    endp
  287.  
  288.  
  289. printer_setup:
  290.  
  291. ; enable help messages
  292.     mov    ebx,7
  293.     lea    eax,print_setup_help_proc
  294.     call    menuoption
  295.  
  296.     xor    ebx,ebx
  297.     lea    esi,printer_menu
  298.     mov    dx,0909h
  299.     mov    eax,offset @curseg:$tpick
  300.     call    pickstring
  301.  
  302. ; disable options
  303.     push    eax
  304.     push    ebx
  305.     mov    ebx,5
  306.     xor    eax,eax
  307.     call    menuoption
  308.     mov    ebx,7
  309.     call    menuoption
  310.     pop    ebx
  311.     pop    eax
  312.  
  313.     cmp    ax,27
  314.     je    printer_setup_exit
  315.  
  316.     cmp    bx,2            ; lines per inch?
  317.     jne    short p5
  318. pf3:
  319.     lea    esi,p2
  320.     call    print_msg
  321.     add    dl,lpi_len
  322.     lea    esi,lpi_prompt
  323.     call    tprintce
  324.     add    dl,lpi_prompt_len
  325.     call    ucursoron
  326.     call    getkey
  327.     call    cursoroff
  328.     cmp    ax,27
  329.     je    short p6
  330.     cmp    ax,'1'
  331.     jb    pf3
  332.     cmp    ax,'5'
  333.     jb    short p4
  334.     je    pf3
  335.     cmp    ax,'8'
  336.     ja    pf3
  337.     je    short p4
  338.     cmp    ax,'7'
  339.     je    pf3
  340. p4:
  341.     mov    lpi,al
  342.     lea    esi,msg3
  343.     call    print_msg
  344.     mov    bx,2
  345. p5:
  346.     movzx    ebx,bx
  347.     call    ljsetup
  348.  
  349.     or    ebx,ebx
  350.     jnz    short printer_flag_on
  351.  
  352. ; turn all flags off
  353.     mov    ecx,4
  354.     lea    esi,printer_msg
  355.  
  356. printer_flags_off:
  357.     push    ecx
  358.     mov    ebx,[esi]
  359.     add    esi,4
  360.     inc    ebx
  361.     call    strlwr
  362.     pop    ecx
  363.     loop    printer_flags_off
  364.     mov    lpi,'6'
  365.     jmp    printer_setup
  366.  
  367. printer_flag_on:
  368.     push    ebx
  369.     mov    ebx,printer_msg[ebx*4]
  370.     call    strupr
  371.     pop    ebx
  372. p6:
  373.     jmp    printer_setup
  374.  
  375. printer_setup_exit:
  376.     ret
  377.  
  378. print_setup_help_proc:
  379.     mov    esi,help_txt[ebx*4]
  380.     jmp    print_msg
  381.  
  382. @curseg    ends
  383.     end
  384.